import java.util.*;
import java.io.*;


public class Day5 {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read2 in = new Read2();

    //1.游游的you
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int q = in.nextInt();
            int[][] a = new int[q][3];
            for(int i=0;i<q;i++) {
                a[i][0]=in.nextInt();
                a[i][1]=in.nextInt();
                a[i][2]=in.nextInt();
            }
            for(int i=0;i<q;i++) {
                int sum=0;//记录分数
                int sumO=a[i][1];//记录o的个数
                if(sumO==0) {
                    System.out.println(0);
                    continue;
                }
                int j=minNum(a[i]);
                sum=a[i][j]*2;
                if(j==1) {
                    System.out.println(sum);
                }else {
                    sumO-=a[i][j];
                    if(sumO > 1) {
                        sum+=(sumO-1);
                    }
                    System.out.println(sum);
                }
            }
        }
    }
    public static int minNum(int[] arr) {
        int k=0;
        int min=arr[0];
        if(arr[0] > arr[1]) {
            k=1;
            min=arr[1];
        }
        if(arr[k] > arr[2]) {
            k=2;
            min=arr[2];
        }
        return k;
    }
    //2.腐烂的苹果
    public static void main(String[] args) {
        
    }


    //3.孩子们的游戏（圆圈中最后剩下的数）
    public int LastRemaining_Solution (int n, int m) {
        // write code here
        List<Integer> list = new LinkedList<>();
        for(int i=0;i<n;i++) {
            list.add(i);
        }
        int k=0;//遍历链表
        for(int i=0;i<n-1;i++) {
            for(int j=0;j<m;j++) {
                if(j==m-1) {//删除
                    list.remove(k);
                    if(k==list.size()) k=0;
                    break;
                }
                if(k==list.size()-1) {//防止下标越界
                    k=0;
                }else {
                    k++;
                }
            }

        }
        return list.get(0);
    }


}

class Read2 // 自定义快速读入
{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException
    {
        while(!st.hasMoreTokens())
        {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    String nextLine() throws IOException
    {
        return bf.readLine();
    }

    int nextInt() throws IOException
    {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException
    {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException
    {
        return Double.parseDouble(next());
    }
}
